layui.use(['index', 'form', 'formX', 'admin'], function () {
    var $ = layui.jquery;
    var index = layui.index;
    var form = layui.form;
    var formX = layui.formX;
    var admin = layui.admin;
    var setter = admin.setter;
    var $body = $('body');
    // 默认加载主页
    index.loadHome({
        menuPath: '/system/main',
        menuName: '<i class="layui-icon layui-icon-home"></i>'
    });

    // 监听提交
    form.on('submit(submit-psw)', function (data) {
        var charType = parseInt(type);
        if (checkPwd(charType, data.field.newPassword)) {
            admin.req(ctx + "system/profile/resetPwd", data.field, function (resp) {
                himio.notice.resp(resp, function () {
                    layer.close(layer.index);
                });
            }, "post")
        }
        return false;
    });

    if (isDefaultModifyPwd || isPasswordExpired) {
        var msg = isDefaultModifyPwd ?
            "当前密码是初始密码，请您尽快修改密码，防止重要信息泄露！" :
            "您的密码已经很久没有修改了，请您尽快修改密码，保护您的信息安全！";
        layer.open({
            type: 1,
            //不显示标题栏
            title: false,
            closeBtn: false,
            area: '300px;',
            shade: 0.8,
            //设定一个id，防止重复弹出
            id: 'LAY_notice1',
            resize: false,
            btn: ['我已知晓'],
            btnAlign: 'c',
            //拖拽模式，0或者1
            moveType: 1,
            content: '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;">' + msg + '</div>',
            success: function (layero, index) {
            }
        });
    }

    if (latest5Notices) {
        // console.log(latest5Notices)
        latest5Notices.forEach(function (notice) {
            if (!admin.getTempData(notice.noticeId + notice.gmtModified, 'indexNotice')) {
                layer.open({
                    type: 1,
                    title: notice.noticeTitle,
                    closeBtn: false,
                    area: '600px',
                    shade: 0.2,
                    id: notice.noticeId,
                    resize: false,
                    btn: ['我已知晓'],
                    btnAlign: 'c',
                    moveType: 1,
                    content: '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;">' + notice.noticeContent + '</div>',
                    success: function (layero, index) {
                    }
                });
                admin.putTempData(notice.noticeId + notice.gmtModified, true, 'indexNotice');
            }
        })
    }


});